package model

import (
	"chitchat_http/util"
	"github.com/doujunyu/gogo/sql_aid"
	"os"
)

//动态图片

const TableByBbsPicture = "self_bbs_picture"

const BbsPictureByFilePath = "bbs_picture"

//根据评论ID进行查找对应的数据

func BbsPictureByBbsIdToData(bbsId *[]interface{})map[int64][]map[string]interface{}{
	//检测是否已经点赞
	bbsPictureSql, args := sql_aid.PgTable(TableByBbsPicture).WhereIn("bbs_id", *bbsId...).ToSql()
	bbsPictureData, _ := sql_aid.DataToMap(PgSql.Query(bbsPictureSql, args...))
	if len(bbsPictureData) == 0 {
		return map[int64][]map[string]interface{}{}
	}
	http := os.Getenv("SERVER_HTTP")
	for _, datum := range bbsPictureData {
		if datum["picture"] != nil {
			datum["picture"] = util.IsPicturePath(datum["picture"].(string),http)
		}
	}
	return util.ArrayColumnGroupByInt64(&bbsPictureData, "bbs_id")
}



